CREATE TABLE IF NOT EXISTS users (
  id CHAR(36) NOT NULL,
  role_id CHAR(36) NOT NULL,
  username VARCHAR(64) NOT NULL,
  email VARCHAR(128) NOT NULL,
  photo VARCHAR(40) NULL,
  password VARCHAR(255) NOT NULL,
  is_active BOOLEAN NOT NULL DEFAULT TRUE,
  created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  CONSTRAINT users_id_primary PRIMARY KEY (id),
  CONSTRAINT users_username_unique UNIQUE (username),
  CONSTRAINT users_email_unique UNIQUE (email),
  CONSTRAINT users_photo_unique UNIQUE (photo),
  CONSTRAINT users_role_id_foreign FOREIGN KEY (role_id)
    REFERENCES roles (id)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT
);

INSERT INTO users (id, role_id, username, email, password, is_active) VALUES
  ('00d95315-a8c9-49d4-9c8f-399abdb36431', '21bf6853-f390-4f08-8cf0-53e85ce4a37e', 'admin', 'admin@email.com', '$2y$12$L4CKXpVqB13ENp58HCivDuk6dCmBzi64Ug.25u3FDKB1IM6GvEXMi', TRUE);
